home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / WRBYTEE.C < prev    next >
C/C++ Source or Header  |  1989-04-27  |  1KB  |  58 lines

  1. /*    wrbytee.c 4.7        */
  2.  
  3. /*F****************************************************************************
  4.  
  5. FUNCTION NAME:    wrbytee
  6.  
  7. ACTION:        Program a byte in EEPROM at the address provided.  If
  8.         the address is -1, then the config register is programmed.
  9.  
  10. PARAMETERS:
  11.         addr:    offset into EEPROM of location to be programmed.
  12.             If addr is -1, then the config register is programmed.
  13.             Otherwise, the value of a addr is restricted to
  14.             being from 0 to EEPROM size minus one.
  15.  
  16.         data:    value to burned into EEPROM.
  17.  
  18. RETURNS:    (void)
  19.  
  20. ******************************************************************************/
  21.  
  22. #define    PROG_TIME    10    /* Programming delay time */
  23. #define    EROM_SIZE    512    /* Size of EEPROM */
  24. #define    PROG_CONFIG    -1    /* indicator to program the config register */
  25. #define ERASED        0xFF    /* value read from EEPROM when it is erased */
  26.  
  27. #include <hc11/io.h>
  28. #include <hc11/config.h>
  29. #include <hc11/directives.h>
  30.  
  31. SMALL
  32. void wrbytee(addr, data)
  33.  
  34.     int    addr;        /* location to be programmed */
  35.     int    data;        /* value to be programmed */
  36.  
  37.     {
  38.     if ((addr != PROG_CONFIG) & (EEPROM[addr&(EROM_SIZE-1)] != ERASED))
  39.         erbytee(addr);    /* cannot erase Config register ! */
  40.  
  41.     HC11.PPROG = EELAT;
  42.  
  43.     if (addr == PROG_CONFIG)
  44.         HC11.CONFIG = data;
  45.     else
  46.         EEPROM[addr&(EROM_SIZE-1)] = data;
  47.  
  48.     HC11.PPROG =  EELAT | EEPGM;
  49.  
  50.     /* delay for 10 milliseconds */
  51.  
  52.     delay(PROG_TIME);
  53.  
  54.     HC11.PPROG = EELAT;
  55.     HC11.PPROG = 0;
  56.  
  57.     }    /* end of wrbytee */
  58.